package com.zkca.xf.ui.activity.personprotect;

import android.content.Intent;
import android.os.Bundle;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.zkca.xf.ConstantsXF;
import com.zkca.xf.R;
import com.zkca.xf.base.BaseTitleActivity;
import com.zkca.xf.model.javabean.JobLBean;
import com.zkca.xf.utils.TimeUtils;

import butterknife.BindView;
import butterknife.ButterKnife;

public class JobCompleteActivity extends BaseTitleActivity {

    @BindView(R.id.jobid)
    TextView jobid;
    @BindView(R.id.devid)
    TextView devid;
    @BindView(R.id.devname)
    TextView devname;
    @BindView(R.id.installposition)
    TextView installposition;
    @BindView(R.id.xunjianuser)
    TextView xunjianuser;
    @BindView(R.id.zuoyetime)
    TextView zuoyetime;
    @BindView(R.id.xunjiantime)
    TextView xunjiantime;
    @BindView(R.id.devstatus)
    TextView devstatus;
    @BindView(R.id.commun)
    TextView commun;
    @BindView(R.id.imagadd)
    ImageView imagadd;
    @BindView(R.id.imaglinear)
    LinearLayout imaglinear;
    @BindView(R.id.imagandtext)
    LinearLayout imagandtext;
    int taskId;
    int jobId;
    String devId;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_job_complete);
        ButterKnife.bind(this);
        setTitleText("作业完成结果");
        setleftTextVisibility(true);
        setleftImgVisibility(true);

        Intent intent = getIntent();
        JobLBean.DataBean jobbean = (JobLBean.DataBean) intent.getSerializableExtra("jobbean");

        jobId = jobbean.getJobId();//作业编号
        devId = jobbean.getDevId();//设备编号
        String devName = jobbean.getDevName();//设备名称
        String installPosition1 = jobbean.getInstallPosition();//设备地点
        taskId = jobbean.getTaskId();//任务ID
        jobid.setText(jobId + "");
        devid.setText(devId);
        devname.setText(devName);
        installposition.setText(installPosition1);
        xunjianuser.setText(jobbean.getUserName());
        long realTime = (long)jobbean.getRealTime();
        long startTime = jobbean.getStartTime();
        long endTime = jobbean.getEndTime();
        String start = TimeUtils.getFormatDate2(startTime);
        String end = TimeUtils.getFormatDate2(endTime);
        String formatDate2 = TimeUtils.getFormatDate2(realTime);
        xunjiantime.setText(formatDate2);
        zuoyetime.setText(start+"----"+end);
        int devStatus = jobbean.getDevStatus();
        if (devStatus==0){
            devstatus.setText("设备安全");
        }else {
            devstatus.setText("设备故障");
        }

        String name1 = (String) jobbean.getComment();
        if (name1!=null){
            boolean contains = name1.contains("<br/>");
            if (contains){
                name1= name1.replace("<br/>","注：");
            }
            commun.setText(name1);
        }

        Glide.with(this).load(ConstantsXF.URL_SERVER_CE + jobbean.getDevImage4()).asBitmap().placeholder(R.mipmap.zwf).error(R.mipmap.zwf).into(imagadd);

    }
}
